package com.mi9688.stream;

import com.mi9688.lambda.Student;

import java.util.Arrays;
import java.util.List;

public class Match {
    public static void main(String[] args) {
        List<Student> students= Arrays.asList(new Student("小明",18),new Student("小黑",16),new Student("小红",17));
        // 判断所有学生年龄是否都大于17
        boolean match = students.stream().allMatch(s -> s.getAge() > 17);
        System.out.println(match);//false
        //判断只要有一个学生年龄小于17
        boolean match1 = students.stream().anyMatch(s -> s.getAge() < 17);
        System.out.println(match1);//true
        //判断没有一个学生年龄大于18
        boolean match2 = students.stream().noneMatch(s -> s.getAge() > 18);
        System.out.println(match2);//true
    }
}
